package com.lzy.product.service.impl;

import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.AgentProtocolCommissionMapperExt;
import com.lzy.product.dtos.agent.AgentProtocolCommissionDto;
import com.lzy.product.entity.AgentProtocolCommission;
import com.lzy.product.service.AgentProtocolCommissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AgentProtocolCommissionServiceImpl implements AgentProtocolCommissionService {

    @Autowired
    private AgentProtocolCommissionMapperExt agentProtocolCommissionMapperExt;

    @Override
    public Long insert(AgentProtocolCommissionDto dto) {
        AgentProtocolCommission agentProtocolCommissiona = DozerUtils.map(dto, AgentProtocolCommission.class);
        return agentProtocolCommissionMapperExt.insertSelective(agentProtocolCommissiona) > 0 ? agentProtocolCommissiona.getId() : 0;
    }

    @Override
    public Boolean update(AgentProtocolCommissionDto dto) {
        return agentProtocolCommissionMapperExt.updateByPrimaryKeySelective(DozerUtils.map(dto, AgentProtocolCommission.class)) > 0;
    }

    @Override
    public Boolean delete(Long id) {
        return null;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public AgentProtocolCommissionDto findById(Long id) {
        return DozerUtils.map(agentProtocolCommissionMapperExt.selectByPrimaryKey(id), AgentProtocolCommissionDto.class);
    }

    @Override
    public List<AgentProtocolCommissionDto> query(AgentProtocolCommissionDto dto) {
        return agentProtocolCommissionMapperExt.query(dto);
    }

    @Override
    public List<AgentProtocolCommissionDto> selectByProtocolId(Long protocolId) {
        return agentProtocolCommissionMapperExt.selectByProtocolId(protocolId);
    }

    @Override
    public Boolean deleteByProtocolId(Long protocolId) {
        return agentProtocolCommissionMapperExt.deleteByProtocolId(protocolId);
    }

    @Override
    public List<AgentProtocolCommissionDto> selectByProtocolIdAndSystemId(Long protocolId, Long systemId,Integer isFirst) {
        return agentProtocolCommissionMapperExt.selectByProtocolIdAndSystemId(protocolId, systemId,isFirst);
    }

    @Override
    public AgentProtocolCommissionDto selectByProtocolIdAndSystemIdAndPromoteId(Long protocolId, Long systemId, Long PromoteId) {
        return agentProtocolCommissionMapperExt.selectByProtocolIdAndSystemIdAndPromoteId( protocolId,  systemId,  PromoteId);
    }

}
